var pic="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg2.doubanio.com%2Fview%2Fphoto%2Fsqs%2Fpublic%2Fp2677102402.jpg&refer=http%3A%2F%2Fimg2.doubanio.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1668176271&t=c5414c4ef8085a27f3474a63842f4a46://www.baidu.com/link?url=IFQ8AABSy5NmlMGTg9a_NpAVZwNwBvxKJz1WMzqHDsB_Dvvbs8GVhAIGYsa_ETf0fZl1pgxdfwNOriUnaSSX7bqV_gGTxl5o6R-k91P_DTneBI3dkNzPOjXFO0zX6wLde0GmsHV0W5jw-K-2L67kgYisCQyj5anmNaWgz9l0G-jr3wzouEKXkDvDmXt1D1ARuKr1iQ7x_R7tPYQQQqj0Phg0U7TInTOg3i4lSalTFo51R07FA7I9Khrl7YpNV2bFfu4WKz0qmmTqd1Pca9eP19h0wBJM_4nMW1oK1y3u2qE0LWsnPrRoyNHy6_utS9Yr7TBgUzjwcdeAVNJC-QC0xhTt5GUtOdU6aOU35DtIAck1SbXNN56XfoalTqYiZBVNO9bpHzUgikzG2M-GfiDrSLKMd0_kDKFJLy7EBFMYcAZ6clDVKx_tC-abVAhyDsoZBi77Exx-7h0x4gxNyM4TKVrtpldGyWBP2wLoWS2u7FwSbMwm8U2ry-a82u0UUxYaCkO9_XmcXshuAmGdTn0rZwJSqMXUEmEynRQi0DPFp5JBMzgxiN6-bsrEz7FgZCiM04rOh-kHCQLjMemFN6CaXmFu3HzramDFlWdyADdqOv2rM1zV63EYGv5bw85lD_O-_iDz3mnt6qjheNSKRXact_&wd=&eqid=c7cdced300003b0b000000026346cb47"
var vw = new Vue({
    el:'#app',
    data:{
        list:[
            {name:'秋刀鱼/斤',price:'10',pic,count:1},
            {name:'大黄鱼/斤',price:'98',pic,count:2},
            {name:'皮皮虾/斤',price:'35',pic,count:3},

        ]
    },

    methods:{
        add(item){
            if(item.count < 5)item.count++;
        },
        sub(item){
            if(item.count > 1)item.count--;
        },
        clean(){
            this.list = [];
        },
    },
    computed:{
        totalCount(){
            var sum = 0;
            this.list.forEach(item => {
                sum += item.count;
            });
            return sum
        },
        totalPrice(){
            var sum = 0;
            this.list.forEach((item)=>{
                sum += item.count * item.price
            })
            return sum
        }
    }
})